﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="QL_News.aspx.cs" Inherits="ChineseSchool.Admin.QL_News" ValidateRequest="false" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .form-horizontal .control-label
        {
            text-align: left;
        }
    </style>
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();
                reader.onload = function (e) {
                    $('.imgDisplay')
                        .attr('src', e.target.result)
                        .width(150);
                };
                reader.readAsDataURL(input.files[0]);
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_Top" runat="server">
    <asp:Panel ID="panAdd" runat="server" Visible="false">
        <div class="row">
            <div class="col-md-10">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <asp:Label ID="lblTitle" runat="server"></asp:Label>
                    </div>
                    <div class="form-horizontal">
                        <div class="box-body">
                            <div class="form-group">
                                <asp:Label ID="lblNewsType" Text="Loại tin tức" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <asp:DropDownList ID="ddlNewsType" runat="server" CssClass="form-control">
                                    </asp:DropDownList>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblImageUrlUpload" Text="Ảnh đại diện:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <div class="radio col-sm-6">
                                        <asp:FileUpload ID="fuImageUrl" runat="server" ToolTip="Tải lên ảnh đại diện" onchange="readURL(this);" />
                                    </div>
                                    <div class="radio col-sm-6">
                                        <asp:Image ID="imgDisplay" CssClass="imgDisplay" runat="server" />
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblIsLock" Text="Hiển thị:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <div class="radio col-sm-2">
                                        <asp:RadioButton ID="rbYes" runat="server" Text="Có" GroupName="rbLock" />
                                    </div>
                                    <div class="radio col-sm-2">
                                        <asp:RadioButton ID="rbNo" runat="server" Text="Không" GroupName="rbLock" />
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblTitleData" Text="Tiêu đề:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <asp:TextBox runat="server" ID="txtTitle" Text='<%# Bind("Title") %>' MaxLength="150"
                                        CssClass="form-control"></asp:TextBox>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblSummary" Text="Tóm tắt:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <FCKeditorV2:FCKeditor ID="txtSummary" runat="server" Height="250px"></FCKeditorV2:FCKeditor>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblNewsContent" Text="Nội dung:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <FCKeditorV2:FCKeditor ID="ckNewsContent" runat="server" Height="800px"></FCKeditorV2:FCKeditor>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <asp:Button ID="btnAdd" runat="server" Text="Thêm mới" CssClass="btnSubmit" OnClick="btnAdd_Click" />
                            <asp:Button ID="btnEdit" runat="server" Text="Cập nhật" CssClass="btnSubmit"
                                OnClick="btnEdit_Click" />
                            <asp:Button ID="btnCancel" runat="server" Text="Hủy" OnClick="btnCancel_Click" />
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
            </div>
        </div>
    </asp:Panel>
    <div class="row">
        <div class="col-xs-12">
            <asp:Label ID="lblThongbao" runat="server" Text="" CssClass="control-label"></asp:Label>
            <div class="box">
                <div class="col-xs-6 box-header with-border">
                    <h3 class="box-title">Danh sách tin tức:</h3>
                </div>
                <div class="col-xs-6 box-header text-right">
                    <asp:Button ID="btnNew2" runat="server" Text="Thêm mới" OnClick="btnNew_Click" />
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <asp:GridView ID="grdNews" runat="server" AutoGenerateColumns="False"
                        AllowPaging="True" EnableModelValidation="True" CssClass="table table-bordered"
                        AllowSorting="True"
                        OnRowCommand="grdNews_RowCommand" OnRowDeleting="grdNews_RowDeleting"
                        OnRowEditing="grdNews_RowEditing" OnPageIndexChanging="grdNews_PageIndexChanging"
                        PageSize="10">
                        <PagerStyle CssClass="grdPaging" HorizontalAlign="Center" VerticalAlign="Middle" />
                        <Columns>
                            <asp:TemplateField HeaderText="Stt" HeaderStyle-Width="20px">
                                <ItemTemplate>
                                    <%# Container.DataItemIndex + 1 %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="NewsID" Visible="false" />
                            <asp:TemplateField ItemStyle-Width="80px" HeaderText="Ảnh đại diện" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <img src='<%# Eval("ImageUrl") %>' width="30px" alt=""></img>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Title" HeaderText="Tiêu đề" HeaderStyle-Width="450px" ReadOnly="true" HtmlEncode="False" />
                            <asp:BoundField DataField="PostDate" HeaderText="Ngày đăng" HeaderStyle-Width="150px"
                                DataFormatString="{0:dd/MM/yyyy hh:mm:ss}" ReadOnly="true" />
                            <asp:TemplateField ItemStyle-Width="20px" HeaderText="Sửa" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:ImageButton ID="imgedit" runat="server" ImageUrl="Images/edit.png" ToolTip="Sửa thông tin"
                                        CommandArgument='<%# Eval("NewsID") %>' CommandName="Edit" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField ItemStyle-Width="20px" HeaderText="Xóa" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:ImageButton ID="imgDel" runat="server" ImageUrl="Images/del.gif" ToolTip="Xóa tin tức"
                                        CommandArgument='<%# Eval("NewsID") %>' CommandName="Delete" OnClientClick=" return confirm('Bạn có chắc chắn muốn xoá?') " />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <div align="left" style="font-weight: bold">
                        <asp:Label ID="lbl_count" runat="server" Visible="false"></asp:Label>
                    </div>
                </div>

                <div class="box-footer clearfix">
                    <div class="col-xs-6 text-left">
                        <i>Bạn đang xem trang
                            <%=grdNews.PageCount==0 &&  grdNews.PageIndex == 0 ? 0 : grdNews.PageIndex+1%>
                            của
                            <%=grdNews.PageCount%></i>
                    </div>
                    <div class="col-xs-6 text-right">
                        <asp:Button ID="btnNew" runat="server" Text="Thêm mới" OnClick="btnNew_Click" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
